package com.dingqb.main.ui;

import android.animation.Animator;
import android.animation.Animator.AnimatorListener;
import android.animation.ObjectAnimator;
import android.app.Activity;
import android.app.Fragment;
import android.os.Bundle;
import android.os.Looper;
import android.os.MessageQueue;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationSet;
import android.view.animation.AnimationUtils;
import android.view.animation.RotateAnimation;
import android.view.animation.ScaleAnimation;
import android.view.animation.TranslateAnimation;
import android.widget.ImageView;
import android.widget.Toast;

import com.dingqb.more.R;

public class AnimateActivity extends Activity {
	
	private ImageView iv_temp1;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_animate);
		iv_temp1=(ImageView) findViewById(R.id.iv_temp1);
		try {
			Animation a=null;a.start(); a.cancel();
			a.hasEnded();a.hasStarted();
			AnimationSet s;
			View view=null;view.startAnimation(a);
			view.clearAnimation();
			ImageView iv=null;
			iv.setBackgroundResource(R.drawable.ic_launcher);
		} catch (Exception e) {
			
		}
		
		
	}

	@Override
	public void onContentChanged() {
		super.onContentChanged();
	}
	@Override
	public void onAttachFragment(Fragment fragment) {
		// TODO Auto-generated method stub
		super.onAttachFragment(fragment);
	}
	public void rotateyAnimRun(View view) {
		ObjectAnimator anim = ObjectAnimator//
				.ofFloat(view, "rotationY", 0.0F, 3600.0F)//
				.setDuration(5000);//
		anim.start();
		anim.addListener(new AnimatorListener() {
			
			@Override
			public void onAnimationStart(Animator animation) {
				
			}
			
			@Override
			public void onAnimationRepeat(Animator animation) {
				
			}
			
			@Override
			public void onAnimationEnd(Animator animation) {
				
			}
			
			@Override
			public void onAnimationCancel(Animator animation) {
				
			}
		});
		
		
		
		//方式一：
		
//		Animation an=AnimationUtils.loadAnimation(this, R.anim.animate_alpha);
//		
//		iv_temp1.startAnimation(an);
//		an.setAnimationListener(new AnimationListener() {
//			
//			@Override
//			public void onAnimationStart(Animation animation) {
//				Toast.makeText(AnimateActivity.this, "onAnimationStart", 0).show();
//			}
//			
//			@Override
//			public void onAnimationRepeat(Animation animation) {
//				
//			}
//			
//			@Override
//			public void onAnimationEnd(Animation animation) {
//				Toast.makeText(AnimateActivity.this, "onAnimationEnd", 0).show();
//			}
//		});
//		方式二：
		AlphaAnimation alphaAnimation=new AlphaAnimation(0, 1);
		alphaAnimation.setRepeatCount(10);
		alphaAnimation.setDuration(1000);
		iv_temp1.startAnimation(alphaAnimation);
		alphaAnimation.setAnimationListener(new AnimationListener() {
			
			@Override
			public void onAnimationStart(Animation animation) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void onAnimationRepeat(Animation animation) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void onAnimationEnd(Animation animation) {
				// TODO Auto-generated method stub
				
			}
		});
//		RotateAnimation;
//		ScaleAnimation
//		TranslateAnimation
		
		// 
		
		
		
	}
}
